<template>
  <div>
    <el-dialog :visible.sync="dialogVisible" :show-close="false" width="800px" @close="close">
      <div class="header">
        <div><span class="line"></span>{{ detail.title }}</div>
        <i class="el-icon-close" @click="close"></i>
      </div>
      <div class="material-tag">
        <span class="tag" v-for="(item, index) in detail.labels">{{ item }}</span>
      </div>
      <div class="material-time">
        上传时间：{{ parseTime(new Date(detail.publishDatetime), '{y}-{m}-{d}') }}
      </div>
      <el-row :gutter="10" class="mb8">
        <!-- 图片 -->
        <div class="material-video" v-if="detail.type === 'img'">
          <img style="width: 100%;" :src="detail.preViewUrl" alt="">
        </div>
        <!-- 视频 -->
        <div class="material-video" v-if="detail.type === 'video'">
          <vue-d-player ref="dplayer" :options="{ video: { url: detail.preViewUrl, pic: detail.coverUrl } }"
            :key="detail.id"></vue-d-player>
        </div>
        <!-- 文本 -->
        <div class="material-desc" v-if="detail.type === 'text'">
          {{ detail.textContent }}
        </div>
      </el-row>
      <!-- <div class="btn">
        <el-row :gutter="40" class="mb8">
          <el-col :span="1.5">
            <el-button plain @click="result">编辑</el-button>
          </el-col>
        </el-row>
      </div> -->
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "Preview",
  data() {
    return {
      title: "",
      dialogVisible: false,
      // 表单参数
      detail: {
        preViewUrl: ''
      },
      dp: null,
      options: {}
    };
  },
  mounted() { },
  methods: {
    close() {
      this.dialogVisible = false;
    },
    result() {
      const player = this.$refs.dplayer.dp
      console.log(player)

      // player.re
    },
    show(detail) {
      this.detail = detail;
      this.dialogVisible = true;
    },
    handleEdit() {

    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["model"].validate((valid, model) => {
        // if (valid) {
        // }
        console.log(valid, model);
      });
    },
  },
};
</script>
<style scoped lang="scss">
.btn {
  width: 100%;
  padding: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.material-video {
  img {
    width: 100%;
  }
}

.material-desc {
  max-height: 500px;
  min-height: 300px;
  // overflow-y: scroll;
  line-height: 22px;
  font-size: 14px;
}

.header {
  display: flex;
  justify-content: space-between;
  padding: 20px 0 0;
  font-size: 18px;
  font-weight: 700;

  .line {
    display: inline-block;
    width: 2px;
    height: 13px;
    background-color: #2552E4;
    margin-right: 5px;
  }

  i {
    font-size: 26px;
    cursor: pointer;
    margin-left: 60px;
  }
}

.material-time {
  margin-bottom: 10px;
  border-bottom: 1px solid #D4DEEA;
  padding-bottom: 10px;
  font-size: 12px;
}

.material-tag {
  margin: 10px 0 10px;

  .tag {
    display: inline-block;
    background: rgba(9, 184, 68, 0.08);
    color: #09B844;
    padding: 3px 10px;
    font-size: 12px;
    border-radius: 2px;
    margin-right: 10px;
  }

  .tag:last-child {
    background: rgba(0, 87, 255, 0.08);
    color: #0057FF;
  }
}

::v-deep {
  .el-dialog__header {
    padding: 0;
  }
}
</style>
